package nc.bs.common.util;

import nc.bs.businessevent.bd.BDCommonEventUtil;
import nc.bs.dao.BaseDAO;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.vo.am.common.util.ArrayConstructor;
import nc.vo.bd.accessor.DefdocAccessorQueryService;
import nc.vo.bd.userdefrule.UserdefitemVO;
import nc.vo.pub.BusinessException;

import java.util.List;

/**
 * @author duanyp1
 * @date 2024/1/16 11:54
 */
public class UserDefItemUtil {

    public UserdefitemVO[] queryUserItem(String entityId) throws BusinessException {
        String sql = "SELECT * FROM bd_userdefitem where dr = 0 and enabled = 'Y' and pk_userdefrule = (" +
                "SELECT pk_userdefrule FROM bd_userdefruleref where dr = 0 and refclass = '"+entityId+"')";
        BaseDAO dao = new BaseDAO();
        List<UserdefitemVO> rs = (List<UserdefitemVO>) dao.executeQuery(sql, new BeanListProcessor(UserdefitemVO.class));
        return ArrayConstructor.getArray(rs);
    }
    public UserdefitemVO[] queryUserItem(Object entity) throws BusinessException {
        BDCommonEventUtil sourceUtil = new BDCommonEventUtil();
        String sourceID = sourceUtil.getSourceID(entity);
        return queryUserItem(sourceID);
    }

}
